package cn.tedu.egmvc3.controller;

import cn.tedu.egmvc3.mapper.UserMapper;
import cn.tedu.egmvc3.pojo.entity.User;
import cn.tedu.egmvc3.pojo.entity.vo.UserListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/users/")
public class UserController {
    @Autowired
    private UserMapper userMapper;
    @RequestMapping("insert")
    public String insert(User user){
        userMapper.insert(user);
        return "添加成功";
    }
    @RequestMapping("delete")
    public String delete(Integer id){
        userMapper.delete(id);
        return "删除成功";
    }
    @RequestMapping("select")
    public List<UserListVO> select(){
        return userMapper.select();
    }
    @RequestMapping("update")
    public String update(User user){
        userMapper.update(user);
        return "修改成功";
    }
}
